package com.example.demo_1106.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo_1106.entity.OrderInfo;
import com.example.demo_1106.service.OrderInfoService;
import com.example.demo_1106.mapper.OrderInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kongke
 * @description 针对表【order_info】的数据库操作Service实现
 * @createDate 2023-07-23 10:09:06
 */
@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo>
        implements OrderInfoService {

    @Autowired
    OrderInfoMapper orderInfoMapper;

    /**
     * 删除订单
     *
     * @param ordercode 订单编号
     * @return boolean
     */
    @Override
    public boolean delOrderinfo(String ordercode) {
        int del = orderInfoMapper.delete(new QueryWrapper<OrderInfo>().eq("order_code", ordercode));
        return del != 0;
    }

    /**
     * 查询订单
     *
     * @param ordercode 订单编号
     * @return {@link List}<{@link OrderInfo}>
     */
    @Override
    public List<OrderInfo> getOrder(String ordercode) {
        List<OrderInfo> orderInfoList;
        if ("".equals(ordercode) || ordercode == null) {
            orderInfoList = orderInfoMapper.selectList(null);
        } else {
            orderInfoList = orderInfoMapper.selectList(new QueryWrapper<OrderInfo>().eq("order_code", ordercode));
        }
        return orderInfoList;
    }
}




